<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>

</head>
<body>

<div id="manage_permission_desc" style="padding:5px;height:auto;background-color:#f3f3f3;text-align: center">
    说明：本页面是配置需要权限控制的页面或路径（不需要权限控制不需配置）；<span style="color: #a45b13">权限标识：</span>可随意填写(不允许重复)；<span style="color: #a45b13">权限路径：</span>要权限控制的路径（不允许重复）；<span style="color: #a45b13">所属角色：</span>给用户分配此角色即可授权访问
</div>
	 <table id="manage_permission" fit="true"></table>
    <script th:inline="none" type="text/javascript" >
        var datas=commonAjax("post","/manage/role/selectallrole",{})
   		$(function(){
	   		 $('#manage_permission').edatagrid({
				 autoSave:true,
	   		  	//pagination:true,
	   			singleSelect:true,
	   		 	striped:true,
	   			fitColumns:true,
		   	    url:'/manage/permission/selectallpermission',
		 	 	//pageList:[1,3,6],
	   	        columns:[[
	   	            {field:'permissionId',title:'id',hidden:true,align:'center'},
	   	            {field:'permissionName',title:'权限名称',align:'center',width:20,editor:{type:'textbox',options:{}}},
					{field:'permissionCode',title:'权限标识',align:'center',width:30,editor:{type:'textbox',options:{}}},
					{field:'permissionUrl',title:'权限路径',align:'center',width:50,editor:{type:'combotree',limitToList:false,options:{required:true,url:'/manage/menu/permissionAllMenu'}},
                        formatter:function (value,row,index){
                            var datas=commonAjax("post","/manage/menu/MenuAllData",{})
                            var text=""
                            datas.forEach(function (val) {
                                if (val.urlPath==value){
                                    text= val.text
                                    return;
                                }else {
                                    text=value
                                }
                            })
                            return text
                        }},
					{field:'roleId',title:'所属角色',align:'center',width:20,editor:{type:'combobox',options:{required:true,url:'/manage/role/selectallrole',valueField:'roleId', textField:'roleName'}},
						formatter:function (value,row,index) {
							var roleName=""
							datas.forEach(function (val) {
								if (val.roleId==value){
									roleName= val.roleName
									return;
								}else {
									roleName="无"
								}
							})
							return roleName
						}},
	   	            {field:'permissionDescription',title:'权限描述',width:100,editor:{type:'textbox',options:{}}}
	   	        ]],
				 saveUrl:"/manage/permission/addpermission",
				 updateUrl:"/manage/permission/updatepermission",
				 onSave:function(index,row){

					 windowsOperation(null,"manage_permission",row);
				 },
	   	  		toolbar:[
		         {text:'添加',iconCls:'icon-add',
		        	 //为按钮绑定单击事件
		        	 handler:function(){$('#manage_permission').edatagrid("addRow"); }
		         },
		         {text:'保存',iconCls:'icon-save',
		        	handler:function(){$('#manage_permission').edatagrid("saveRow"); }
		        },
		         {text:'删除',iconCls:'icon-remove',
		        	 handler:function(){
		        		 //获取选中的行
		        		var objs=$('#manage_permission').datagrid('getSelections');
		        		if(objs.length>0){
			        		$.messager.confirm('确认','您确认想要删除这<span style="color:red;">'+objs.length+'</span>条权限吗？',function(r){    
			        		    if (r){    
			        		        $.post({
			        		        	url:'/manage/permission/deletePermission',
			        		        	data:JSON.stringify(objs),
			        		        	contentType:'application/json',
			        		        	success:function(data){
			        		        		if(data.statu==200){
			        		        			windowsOperation(null,"manage_permission",data);
			        		        		}
			        		        	}
			        		        })    
			        		    }    
			        		}); 
		        		}else{
		        			layer.msg('至少要选择一行进行删除');
		        		}
		        	 }
		         }]

	   	    });
   			
   		})
    	
    </script>
</body>
</html>